package io.shdxhl.simplerpc.code.config;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import io.shdxhl.simplerpc.code.cache.impl.SimpleCacheLoader;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
public class SimpleCacheConfig {

    @Bean
    public LoadingCache<String, Object> loadingCache() {
        return CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.SECONDS)
                .maximumSize(10).build(new SimpleCacheLoader());
    }

}
